package com.jierui.meter.frontend.domain;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.jierui.meter.frontend.base.enums.BaseEnum;
import lombok.Getter;

/**
 * 异常编码Enum
 */
@Getter
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum ExceptionCodeEnum implements BaseEnum {
    DIANNENGBIAOSHIZHIBUPING("0101", "电能表示值不平"),
    DIANNENGBIAOFEIZOU("0102", "电能表飞走"),
    DIANENNGBIAODAOZOU("0103", "电能表倒走"),
    DIANNENGBIAODTINGZOU("0104", "电能表停走"),
    DIANNENGBIAOFEILVYICHANG("0105", "电能表费率设置异常"),
    DIANLIANGBODONGYICHANG("0106", "电量波动异常"),
    DIANYADUANXIANG("0201", "电压断相"),
    DIANYAYUEXIAN("0202", "电压越限"),
    DIANYABUPINGHENG("0203", "电压不平衡"),
    BXIANGYICHANG("0204", "高供高计B相异常"),
    DIANYAYICHANG("0205", "电压异常（未区分失压和断相）"),
    LINGXIANYICHANG("0206", "零线异常（电压不平衡或电压越上上限）"),
    DIANLIUSHILIU("0207", "电流失流"),
    DIANLIUBUPINGHENG("0208", "电流不平衡"),
    DIANNENGBIAOKAIBIAOGAI("0301", "电能表开表盖"),
    DIANNENGBIAOKAIDUANNIUHE("0302", "电能表开端钮盒"),
    JILIANGMENKAIBI("0303", "计量门开闭"),
    HENGDINGCICHANGGANRAO("0304", "恒定磁场干扰"),
    DIANLIANGCHADONGYICHANG("0305", "电量差动异常"),
    GONGLVCHADONGYICHANG("0306", "功率差动异常"),
    TINGDIANSHIJIANYICHANG("0307", "停电事件异常"),
    XULIANGCHAORONG("0401", "需量超容"),
    FUHECHAORONG("0402", "负荷超容"),
    DIANLIUGUOLIU("0403", "电流过流"),
    FUHECHIXUCHAOXIAXIAN("0404", "负荷持续超下限"),
    ZHONGDUANSHIZHONGYICHANG("0501", "终端时钟异常"),
    DIANENGBIAOSHIZHONGYICHANG("0502", "电能表时钟异常"),
    FANXIANGDIANLIANGYICHANG("0601", "反向电量异常"),
    XIANGXUYICHANG("0602", "相序异常"),
    CHAOLIUFANXIANG("0603", "潮流反向"),
    DANXIANGBIAOFENLIU("0604", "单相表分流"),
    FEIKONGXIAFAYICHANG("0701", "费控下发异常"),
    SHENGYUJINEYICHANG("0702", "剩余金额异常"),
    ERCIDUANLU("0801", "二次短路（分流）"),
    ERCIKAILU("0802", "二次开路"),
    YICIDUANLU("0803", "一次短路"),
    DUANJIEDIANNENGBIAO("0804", "短接电能表"),
    DIANNENGBIAOJILIANGZHICUOWU("0805", "电能表计量示值错误"),
    HUILUCHUANJIEBANDAOTI("0806", "回路串接半导体"),
    CICHANGYICHANG("0807", "磁场异常"),
    TEST1("0223", "测试1"),
    TEST2("0222", "测试2"),
    TEST3("0224", "测试3"),
    ;


    private String value;
    private String name;

    public String getValue() {
        return value;
    }

    public String getName() {
        return name;
    }

    ExceptionCodeEnum(String value, String name) {
        this.value=value;
        this.name=name;
    }

    public static String getName(String index) {
        for (ExceptionCodeEnum c : ExceptionCodeEnum.values()) {
            if (c.getValue().equals(index)) {
                return c.name;
            }
        }
        return null;
    }
}
